﻿namespace WMS6.BLL
{
    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.Data.Common;
    using WMS6.Common;
    using WMS6.DataEntity;
    using WMS6.DBUtility;
    using WMS6.IDAL;
    using WMS6.QueryEntity;
    using WMS6.DALFactory;

    public class InvHoldBLL
    {
        private static readonly ICommonMethodDA commonMethod = DataAccess.CreateCommonMethod();
        private List<string> dataBaseID;
        private static readonly IInvHoldDA invHoldDA = DataAccess.CreateInvHoldDA();
        private static readonly IInvLotDA invLotDA = DataAccess.CreateInvLotDA();
        private static readonly IInvLotLocLpnDA invLotLocLpnDA = DataAccess.CreateInvLotLocLpnDA();
        private static readonly ILocationDA locationDA = DataAccess.CreateLocationDA();
        private static readonly ILocationDA LocDA = DataAccess.CreateLocationDA();
        private static readonly ILotAttributeDA LotDA = DataAccess.CreateLotAttributeDA();
        private static readonly ILpnDA lpnDA = DataAccess.CreateLpnDA();
        private static readonly IOwnerDA ownerDA = DataAccess.CreateOwnerDA();
        private PubParasInfo pubParasInfo;
        private static readonly ISkuDA skuDA = DataAccess.CreateSkuDA();

        public InvHoldBLL()
        {
            this.pubParasInfo = null;
        }

        public InvHoldBLL(string currentWH)
        {
            this.pubParasInfo = null;
            if (!string.IsNullOrEmpty(currentWH))
            {
                this.dataBaseID = commonMethod.GetDataBaseID(currentWH);
                if (this.dataBaseID == null)
                {
                    PublicMethod.GetInstance().ShowAlertMessage("C001");
                }
            }
            else
            {
                PublicMethod.GetInstance().ShowAlertMessage("C002");
            }
        }

        public InvHoldBLL(PubParasInfo tempPubParasInfo)
        {
            this.pubParasInfo = null;
            if (!string.IsNullOrEmpty(tempPubParasInfo.CurrentWH))
            {
                this.dataBaseID = commonMethod.GetDataBaseID(tempPubParasInfo.CurrentWH);
                if (this.dataBaseID == null)
                {
                    PublicMethod.GetInstance().ShowAlertMessage("C001", this.pubParasInfo.UserLanguage);
                }
                else
                {
                    this.pubParasInfo = new PubParasInfo();
                    this.pubParasInfo = tempPubParasInfo;
                }
            }
            else
            {
                PublicMethod.GetInstance().ShowAlertMessage("C002", this.pubParasInfo.UserLanguage);
            }
        }

        public string Delete(List<string> invHoldIDs)
        {
            string invHoldID = string.Empty;
            DataBase dataBase = new DataBase();
            DbConnection conn = dataBase.connection;
            conn.Open();
            DbTransaction tran = conn.BeginTransaction();
            try
            {
                List<InvHoldInfo> invHoldInfos = new List<InvHoldInfo>();
                InvHoldInfo invHoldInfo = null;
                foreach (string id in invHoldIDs)
                {
                    invHoldInfo = invHoldDA.GetInvHoldByID(dataBase, tran, id, this.dataBaseID[0]);
                    invHoldInfos.Add(invHoldInfo);
                }
                AuditDataBLL auditDataBLL = new AuditDataBLL();
                if (invHoldDA.DeleteInvHold(dataBase, tran, invHoldIDs, this.dataBaseID) > 0)
                {
                    for (int i = 0; i < invHoldIDs.Count; i++)
                    {
                        auditDataBLL.InsertAuditData<InvHoldInfo>(dataBase, tran, invHoldInfos[i], null, AuditAction.Delete, this.pubParasInfo.UserID, "INV_HOLD", this.dataBaseID[0]);
                        invHoldID = invHoldID + invHoldID + ",";
                    }
                    invHoldID = invHoldID.Substring(0, invHoldID.Length - 1);
                }
                tran.Commit();
            }
            catch (Exception ex)
            {
                tran.Rollback();
                CommonErrorHandler.ErrorHandler(ex, LogType.Error);
            }
            finally
            {
                conn.Close();
            }
            return invHoldID;
        }

        public string ExecuteInvHold(InvHoldInfo invHoldInfo)
        {
            DataBase dataBase = new DataBase();
            DbConnection conn = dataBase.connection;
            conn.Open();
            DbTransaction tran = conn.BeginTransaction();
            try
            {
                this.ExecuteInvHold(dataBase, tran, invHoldInfo);
                tran.Commit();
            }
            catch (Exception ex)
            {
                tran.Rollback();
                CommonErrorHandler.ErrorHandler(ex, LogType.Error);
            }
            finally
            {
                conn.Close();
            }
            return invHoldInfo.InvHoldID;
        }

        public string ExecuteInvHold(DataBase dataBase, DbTransaction tran, InvHoldInfo invHoldInfo)
        {
            string whLoginID = this.dataBaseID[0];
            string invHoldID = string.Empty;
            string holdStatus = string.Empty;
            try
            {
                if (!string.IsNullOrEmpty(invHoldInfo.OwnerID))
                {
                    if (!ownerDA.CheckTradePartnerIDUnique(dataBase, tran, invHoldInfo.OwnerID, this.dataBaseID[0]))
                    {
                        PublicMethod.GetInstance().ShowAlertMessage("F5250_001", this.pubParasInfo.UserLanguage, new List<string> { invHoldInfo.OwnerID });
                    }
                    else if (!commonMethod.CheckAuthorizationOwnerByUserID(dataBase, tran, this.pubParasInfo.UserID, invHoldInfo.OwnerID))
                    {
                        PublicMethod.GetInstance().ShowAlertMessage("F5250_002", this.pubParasInfo.UserLanguage, new List<string> { invHoldInfo.OwnerID });
                    }
                }
                if (!string.IsNullOrEmpty(invHoldInfo.SkuID) && !skuDA.CheckSkuIDUnique(dataBase, tran, invHoldInfo.OwnerID, invHoldInfo.SkuID, whLoginID))
                {
                    PublicMethod.GetInstance().ShowAlertMessage("F5250_003", this.pubParasInfo.UserLanguage, new List<string> { invHoldInfo.OwnerID, invHoldInfo.SkuID });
                }
                if (!string.IsNullOrEmpty(invHoldInfo.Loc) && !LocDA.CheckLocationIDUnique(dataBase, tran, invHoldInfo.Loc, whLoginID))
                {
                    PublicMethod.GetInstance().ShowAlertMessage("F5250_004", this.pubParasInfo.UserLanguage, new List<string> { invHoldInfo.OwnerID });
                }
                if (!string.IsNullOrEmpty(invHoldInfo.Lot) && !LotDA.CheckLotAttributeIDUnique(dataBase, tran, invHoldInfo.Lot, whLoginID))
                {
                    PublicMethod.GetInstance().ShowAlertMessage("F5250_005", this.pubParasInfo.UserLanguage, new List<string> { invHoldInfo.Lot });
                }
                if (!string.IsNullOrEmpty(invHoldInfo.LpnID) && !lpnDA.CheckLpnIDUnique(dataBase, tran, invHoldInfo.LpnID, whLoginID))
                {
                    PublicMethod.GetInstance().ShowAlertMessage("F5250_006", this.pubParasInfo.UserLanguage, new List<string> { invHoldInfo.LpnID });
                }
                if (invHoldInfo.IsHold == "Y")
                {
                    holdStatus = InvHoldStatus.HOLD;
                    if (string.IsNullOrEmpty(invHoldInfo.InvHoldID))
                    {
                        invHoldID = commonMethod.GenNextNumStr(dataBase, tran, "INV_HOLD", whLoginID);
                        invHoldInfo.InvHoldID = invHoldID;
                        invHoldDA.InsertInvHold(dataBase, tran, invHoldInfo, whLoginID);
                    }
                    else
                    {
                        invHoldDA.UpdateInvHold(dataBase, tran, invHoldInfo, whLoginID);
                    }
                }
                else
                {
                    holdStatus = InvHoldStatus.OK;
                    invHoldDA.UpdateInvHold(dataBase, tran, invHoldInfo, whLoginID);
                }
                string CS40002 = invHoldInfo.HoldType.ToUpper();
                if (CS40002 != null)
                {
                    if (!(CS40002 == "LOTLOCLPN"))
                    {
                        if (CS40002 == "OWNER")
                        {
                            goto Label_034C;
                        }
                        if (CS40002 == "SKU")
                        {
                            goto Label_0359;
                        }
                    }
                    else
                    {
                        this.InvHoldByLotLocLpn(dataBase, tran, invHoldInfo, holdStatus);
                    }
                }
                goto Label_0378;
            Label_034C:
                this.InvHoldByOwner(dataBase, tran, invHoldInfo, holdStatus);
                goto Label_0378;
            Label_0359:
                this.InvHoldBySku(dataBase, tran, invHoldInfo, holdStatus);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorHandler(ex, LogType.Error);
            }
        Label_0378:
            return invHoldInfo.InvHoldID;
        }

        public InvHoldInfo GetInvHoldInfoByID(string invHoldID)
        {
            return invHoldDA.GetInvHoldByID(invHoldID, this.dataBaseID[0]);
        }

        public DataSet GetInvHoldInfoByQueryEntity(InvHoldQueryEntity invHoldQueryEntity)
        {
            InvHoldQueryEntity invHoldQuery = invHoldQueryEntity;
            List<string> sqlWhere = new List<string>();
            if (!string.IsNullOrEmpty(invHoldQuery.InvHoldID))
            {
                sqlWhere.Add(" INV_HOLD_ID " + invHoldQuery.InvHoldID);
            }
            if (!string.IsNullOrEmpty(invHoldQuery.Lot))
            {
                sqlWhere.Add(" LOT " + invHoldQuery.Lot);
            }
            if (!string.IsNullOrEmpty(invHoldQuery.LpnID))
            {
                sqlWhere.Add(" LPN_ID " + invHoldQuery.LpnID);
            }
            if (!string.IsNullOrEmpty(invHoldQuery.Loc))
            {
                sqlWhere.Add(" LOC " + invHoldQuery.Loc);
            }
            if (!string.IsNullOrEmpty(invHoldQuery.OwnerID))
            {
                sqlWhere.Add(" OWNER_ID " + invHoldQuery.OwnerID);
            }
            if (!string.IsNullOrEmpty(invHoldQuery.SkuID))
            {
                sqlWhere.Add(" SKU_ID " + invHoldQuery.SkuID);
            }
            if (!string.IsNullOrEmpty(invHoldQuery.IsHold))
            {
                sqlWhere.Add(" IS_HOLD " + invHoldQuery.IsHold);
            }
            if (!string.IsNullOrEmpty(invHoldQuery.HoldReasonCode))
            {
                sqlWhere.Add(" HOLD_REASON_CODE " + invHoldQuery.HoldReasonCode);
            }
            if (!string.IsNullOrEmpty(invHoldQuery.HoldBy))
            {
                sqlWhere.Add(" HOLD_BY " + invHoldQuery.HoldBy);
            }
            if (!string.IsNullOrEmpty(invHoldQuery.HoldDate))
            {
                sqlWhere.Add(invHoldQuery.HoldDate.Replace("@HoldDate@", " HOLD_DATE "));
            }
            if (!string.IsNullOrEmpty(invHoldQuery.ReleasedBy))
            {
                sqlWhere.Add(" RELEASED_BY " + invHoldQuery.ReleasedBy);
            }
            if (!string.IsNullOrEmpty(invHoldQuery.ReleasedDate))
            {
                sqlWhere.Add(" RELEASED_DATE " + invHoldQuery.ReleasedDate);
            }
            return invHoldDA.GetInvHoldByQueryList(sqlWhere, invHoldQuery, this.dataBaseID[0]);
        }

        public string Insert(InvHoldInfo invHoldInfo)
        {
            string invHoldID = string.Empty;
            try
            {
                if (invHoldDA.InsertInvHold(invHoldInfo, this.dataBaseID[0]) > 0)
                {
                    new AuditDataBLL().InsertAuditData<InvHoldInfo>(null, invHoldInfo, AuditAction.Insert, this.pubParasInfo.UserID, "INV_HOLD", this.dataBaseID[0]);
                    invHoldID = invHoldInfo.InvHoldID;
                }
                return invHoldID;
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorHandler(ex, LogType.Error);
            }
            return invHoldID;
        }

        public void InvHoldByLotLocLpn(DataBase dataBase, DbTransaction tran, InvHoldInfo invHoldInfo, string holdStatus)
        {
            string whLoginID = this.dataBaseID[0];
            if ((!string.IsNullOrEmpty(invHoldInfo.Lot) && string.IsNullOrEmpty(invHoldInfo.Loc)) && string.IsNullOrEmpty(invHoldInfo.LpnID))
            {
                if (holdStatus == InvHoldStatus.HOLD)
                {
                    invLotDA.ExecuteInvLotHold(dataBase, tran, holdStatus, "LOT", invHoldInfo.Lot, invHoldInfo.Loc, invHoldInfo.LpnID, invHoldInfo.OwnerID, invHoldInfo.SkuID, invHoldInfo.UpdatedBy, whLoginID);
                    invLotLocLpnDA.ExecuteInvLotLocLpnHold(dataBase, tran, holdStatus, "LOT", invHoldInfo, whLoginID);
                }
                else
                {
                    invLotLocLpnDA.ExecuteInvLotLocLpnHold(dataBase, tran, holdStatus, "LOT", invHoldInfo, whLoginID);
                    invLotDA.ExecuteInvLotHold(dataBase, tran, holdStatus, "LOT", invHoldInfo.Lot, invHoldInfo.Loc, invHoldInfo.LpnID, invHoldInfo.OwnerID, invHoldInfo.SkuID, invHoldInfo.UpdatedBy, whLoginID);
                }
            }
            if ((!string.IsNullOrEmpty(invHoldInfo.Loc) && string.IsNullOrEmpty(invHoldInfo.Lot)) && string.IsNullOrEmpty(invHoldInfo.LpnID))
            {
                if (holdStatus == InvHoldStatus.HOLD)
                {
                    invLotDA.ExecuteInvLotHold(dataBase, tran, holdStatus, "LOC", invHoldInfo.Lot, invHoldInfo.Loc, invHoldInfo.LpnID, invHoldInfo.OwnerID, invHoldInfo.SkuID, invHoldInfo.UpdatedBy, whLoginID);
                    locationDA.ExecuteLocationHold(dataBase, tran, holdStatus, invHoldInfo.UpdatedBy, invHoldInfo.Loc, whLoginID);
                    invLotLocLpnDA.ExecuteInvLotLocLpnHold(dataBase, tran, holdStatus, "LOC", invHoldInfo, whLoginID);
                }
                else
                {
                    locationDA.ExecuteLocationHold(dataBase, tran, holdStatus, invHoldInfo.UpdatedBy, invHoldInfo.Loc, whLoginID);
                    invLotLocLpnDA.ExecuteInvLotLocLpnHold(dataBase, tran, holdStatus, "LOC", invHoldInfo, whLoginID);
                    invLotDA.ExecuteInvLotHold(dataBase, tran, holdStatus, "LOC", invHoldInfo.Lot, invHoldInfo.Loc, invHoldInfo.LpnID, invHoldInfo.OwnerID, invHoldInfo.SkuID, invHoldInfo.UpdatedBy, whLoginID);
                }
            }
            if ((!string.IsNullOrEmpty(invHoldInfo.LpnID) && string.IsNullOrEmpty(invHoldInfo.Lot)) && string.IsNullOrEmpty(invHoldInfo.Loc))
            {
                if (holdStatus == InvHoldStatus.HOLD)
                {
                    invLotDA.ExecuteInvLotHold(dataBase, tran, holdStatus, "LPN", invHoldInfo.Lot, invHoldInfo.Loc, invHoldInfo.LpnID, invHoldInfo.OwnerID, invHoldInfo.SkuID, invHoldInfo.UpdatedBy, whLoginID);
                    lpnDA.ExecuteLpnHold(dataBase, tran, holdStatus, invHoldInfo.LpnID, invHoldInfo.UpdatedBy, whLoginID);
                    invLotLocLpnDA.ExecuteInvLotLocLpnHold(dataBase, tran, holdStatus, "LPN", invHoldInfo, whLoginID);
                }
                else
                {
                    lpnDA.ExecuteLpnHold(dataBase, tran, holdStatus, invHoldInfo.LpnID, invHoldInfo.UpdatedBy, whLoginID);
                    invLotLocLpnDA.ExecuteInvLotLocLpnHold(dataBase, tran, holdStatus, "LPN", invHoldInfo, whLoginID);
                    invLotDA.ExecuteInvLotHold(dataBase, tran, holdStatus, "LPN", invHoldInfo.Lot, invHoldInfo.Loc, invHoldInfo.LpnID, invHoldInfo.OwnerID, invHoldInfo.SkuID, invHoldInfo.UpdatedBy, whLoginID);
                }
            }
            if ((!string.IsNullOrEmpty(invHoldInfo.Lot) && !string.IsNullOrEmpty(invHoldInfo.Loc)) && string.IsNullOrEmpty(invHoldInfo.LpnID))
            {
                if (holdStatus == InvHoldStatus.HOLD)
                {
                    invLotDA.ExecuteInvLotHold(dataBase, tran, holdStatus, "LOT_LOC", invHoldInfo.Lot, invHoldInfo.Loc, invHoldInfo.LpnID, invHoldInfo.OwnerID, invHoldInfo.SkuID, invHoldInfo.UpdatedBy, whLoginID);
                    locationDA.ExecuteLocationHold(dataBase, tran, holdStatus, invHoldInfo.UpdatedBy, invHoldInfo.Loc, whLoginID);
                    invLotLocLpnDA.ExecuteInvLotLocLpnHold(dataBase, tran, holdStatus, "LOT_LOC", invHoldInfo, whLoginID);
                }
                else
                {
                    locationDA.ExecuteLocationHold(dataBase, tran, holdStatus, invHoldInfo.UpdatedBy, invHoldInfo.Loc, whLoginID);
                    invLotLocLpnDA.ExecuteInvLotLocLpnHold(dataBase, tran, holdStatus, "LOT_LOC", invHoldInfo, whLoginID);
                    invLotDA.ExecuteInvLotHold(dataBase, tran, holdStatus, "LOT_LOC", invHoldInfo.Lot, invHoldInfo.Loc, invHoldInfo.LpnID, invHoldInfo.OwnerID, invHoldInfo.SkuID, invHoldInfo.UpdatedBy, whLoginID);
                }
            }
            if ((!string.IsNullOrEmpty(invHoldInfo.Lot) && !string.IsNullOrEmpty(invHoldInfo.LpnID)) && string.IsNullOrEmpty(invHoldInfo.Loc))
            {
                if (holdStatus == InvHoldStatus.HOLD)
                {
                    invLotDA.ExecuteInvLotHold(dataBase, tran, holdStatus, "LOT_LPN", invHoldInfo.Lot, invHoldInfo.Loc, invHoldInfo.LpnID, invHoldInfo.OwnerID, invHoldInfo.SkuID, invHoldInfo.UpdatedBy, whLoginID);
                    lpnDA.ExecuteLpnHold(dataBase, tran, holdStatus, invHoldInfo.LpnID, invHoldInfo.UpdatedBy, whLoginID);
                    invLotLocLpnDA.ExecuteInvLotLocLpnHold(dataBase, tran, holdStatus, "LOT_LPN", invHoldInfo, whLoginID);
                }
                else
                {
                    lpnDA.ExecuteLpnHold(dataBase, tran, holdStatus, invHoldInfo.LpnID, invHoldInfo.UpdatedBy, whLoginID);
                    invLotLocLpnDA.ExecuteInvLotLocLpnHold(dataBase, tran, holdStatus, "LOT_LPN", invHoldInfo, whLoginID);
                    invLotDA.ExecuteInvLotHold(dataBase, tran, holdStatus, "LOT_LPN", invHoldInfo.Lot, invHoldInfo.Loc, invHoldInfo.LpnID, invHoldInfo.OwnerID, invHoldInfo.SkuID, invHoldInfo.UpdatedBy, whLoginID);
                }
            }
            if ((!string.IsNullOrEmpty(invHoldInfo.Loc) && !string.IsNullOrEmpty(invHoldInfo.LpnID)) && string.IsNullOrEmpty(invHoldInfo.Lot))
            {
                if (holdStatus == InvHoldStatus.HOLD)
                {
                    invLotDA.ExecuteInvLotHold(dataBase, tran, holdStatus, "LOC_LPN", invHoldInfo.Lot, invHoldInfo.Loc, invHoldInfo.LpnID, invHoldInfo.OwnerID, invHoldInfo.SkuID, invHoldInfo.UpdatedBy, whLoginID);
                    locationDA.ExecuteLocationHold(dataBase, tran, holdStatus, invHoldInfo.UpdatedBy, invHoldInfo.Loc, whLoginID);
                    lpnDA.ExecuteLpnHold(dataBase, tran, holdStatus, invHoldInfo.LpnID, invHoldInfo.UpdatedBy, whLoginID);
                    invLotLocLpnDA.ExecuteInvLotLocLpnHold(dataBase, tran, holdStatus, "LOC_LPN", invHoldInfo, whLoginID);
                }
                else
                {
                    locationDA.ExecuteLocationHold(dataBase, tran, holdStatus, invHoldInfo.UpdatedBy, invHoldInfo.Loc, whLoginID);
                    lpnDA.ExecuteLpnHold(dataBase, tran, holdStatus, invHoldInfo.LpnID, invHoldInfo.UpdatedBy, whLoginID);
                    invLotLocLpnDA.ExecuteInvLotLocLpnHold(dataBase, tran, holdStatus, "LOC_LPN", invHoldInfo, whLoginID);
                    invLotDA.ExecuteInvLotHold(dataBase, tran, holdStatus, "LOC_LPN", invHoldInfo.Lot, invHoldInfo.Loc, invHoldInfo.LpnID, invHoldInfo.OwnerID, invHoldInfo.SkuID, invHoldInfo.UpdatedBy, whLoginID);
                }
            }
            if ((!string.IsNullOrEmpty(invHoldInfo.Lot) && !string.IsNullOrEmpty(invHoldInfo.Loc)) && !string.IsNullOrEmpty(invHoldInfo.LpnID))
            {
                if (holdStatus == InvHoldStatus.HOLD)
                {
                    invLotDA.ExecuteInvLotHold(dataBase, tran, holdStatus, "LOT_LOC_LPN", invHoldInfo.Lot, invHoldInfo.Loc, invHoldInfo.LpnID, invHoldInfo.OwnerID, invHoldInfo.SkuID, invHoldInfo.UpdatedBy, whLoginID);
                    lpnDA.ExecuteLpnHold(dataBase, tran, holdStatus, invHoldInfo.LpnID, invHoldInfo.UpdatedBy, whLoginID);
                    locationDA.ExecuteLocationHold(dataBase, tran, holdStatus, invHoldInfo.UpdatedBy, invHoldInfo.Loc, whLoginID);
                    invLotLocLpnDA.ExecuteInvLotLocLpnHold(dataBase, tran, holdStatus, "LOT_LOC_LPN", invHoldInfo, whLoginID);
                }
                else
                {
                    lpnDA.ExecuteLpnHold(dataBase, tran, holdStatus, invHoldInfo.LpnID, invHoldInfo.UpdatedBy, whLoginID);
                    locationDA.ExecuteLocationHold(dataBase, tran, holdStatus, invHoldInfo.UpdatedBy, invHoldInfo.Loc, whLoginID);
                    invLotLocLpnDA.ExecuteInvLotLocLpnHold(dataBase, tran, holdStatus, "LOT_LOC_LPN", invHoldInfo, whLoginID);
                    invLotDA.ExecuteInvLotHold(dataBase, tran, holdStatus, "LOT_LOC_LPN", invHoldInfo.Lot, invHoldInfo.Loc, invHoldInfo.LpnID, invHoldInfo.OwnerID, invHoldInfo.SkuID, invHoldInfo.UpdatedBy, whLoginID);
                }
            }
        }

        public void InvHoldByOwner(DataBase dataBase, DbTransaction tran, InvHoldInfo invHoldInfo, string holdStatus)
        {
            string whLoginID = this.dataBaseID[0];
            if (holdStatus == InvHoldStatus.HOLD)
            {
                invLotDA.ExecuteInvLotHold(dataBase, tran, holdStatus, "OWNER", invHoldInfo.Lot, invHoldInfo.Loc, invHoldInfo.LpnID, invHoldInfo.OwnerID, invHoldInfo.SkuID, invHoldInfo.UpdatedBy, whLoginID);
                invLotLocLpnDA.ExecuteInvLotLocLpnHold(dataBase, tran, holdStatus, "OWNER", invHoldInfo, whLoginID);
            }
            else
            {
                invLotLocLpnDA.ExecuteInvLotLocLpnHold(dataBase, tran, holdStatus, "OWNER", invHoldInfo, whLoginID);
                invLotDA.ExecuteInvLotHold(dataBase, tran, holdStatus, "OWNER", invHoldInfo.Lot, invHoldInfo.Loc, invHoldInfo.LpnID, invHoldInfo.OwnerID, invHoldInfo.SkuID, invHoldInfo.UpdatedBy, whLoginID);
            }
        }

        public void InvHoldBySku(DataBase dataBase, DbTransaction tran, InvHoldInfo invHoldInfo, string holdStatus)
        {
            string whLoginID = this.dataBaseID[0];
            if (holdStatus == InvHoldStatus.HOLD)
            {
                invLotDA.ExecuteInvLotHold(dataBase, tran, holdStatus, "SKU", invHoldInfo.Lot, invHoldInfo.Loc, invHoldInfo.LpnID, invHoldInfo.OwnerID, invHoldInfo.SkuID, invHoldInfo.UpdatedBy, whLoginID);
                invLotLocLpnDA.ExecuteInvLotLocLpnHold(dataBase, tran, holdStatus, "SKU", invHoldInfo, whLoginID);
            }
            else
            {
                invLotLocLpnDA.ExecuteInvLotLocLpnHold(dataBase, tran, holdStatus, "SKU", invHoldInfo, whLoginID);
                invLotDA.ExecuteInvLotHold(dataBase, tran, holdStatus, "SKU", invHoldInfo.Lot, invHoldInfo.Loc, invHoldInfo.LpnID, invHoldInfo.OwnerID, invHoldInfo.SkuID, invHoldInfo.UpdatedBy, whLoginID);
            }
        }
    }
}

